export default class ScorePanel {
  score = 0
  level = 1

  scoreEle: HTMLElement
  levelEle: HTMLElement

  maxLevel: number
  scoreToUpgrade: number

  constructor(maxLevel: number = 10, scoreToUpgrade: number = 10) {
    this.scoreEle = document.getElementById('score')!
    this.levelEle = document.getElementById('level')!

    this.maxLevel = maxLevel
    this.scoreToUpgrade = scoreToUpgrade
  }

  addScore() {
    this.scoreEle.innerHTML = ++this.score + ''

    if (this.score % this.scoreToUpgrade === 0) {
      this.addLevel()
    }
  }

  addLevel() {
    if (this.level < this.maxLevel) {
      this.levelEle.innerHTML = ++this.level + ''
    }
  }
}
